package com.flight.trans.adapter;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flight.trans.R;
import com.flight.trans.base.BaseRecyclerAdapter;
import com.flight.trans.base.BaseViewHolder;
import com.flight.trans.bean.LeavePortReturnBean.LeavePortReturnData;
import com.flight.trans.util.CommonUtils;

import java.util.List;

/**
 * 出港退运
 */
public class LeavePorReturnAdapter extends BaseRecyclerAdapter<LeavePortReturnData> {

    private boolean IsEditor ;

    public LeavePorReturnAdapter(Context mContext, List<LeavePortReturnData> mList , boolean IsEditor) {
        super(mContext, mList);
        this.IsEditor = IsEditor ;
    }

    @Override
    public int setContentView() {
        return R.layout.adapter_leave_port_return;
    }

    @Override
    protected void bindData(BaseViewHolder holder, LeavePortReturnData data, int position) {
        LinearLayout mLlContainerItem = holder.findViewById(R.id.mLlContainerItem);
        TextView mTvOrderNo = holder.findViewById(R.id.mTvOrderNo);
        TextView mTvRealCount = holder.findViewById(R.id.mTvRealCount);
        TextView mTvRealWeight = holder.findViewById(R.id.mTvRealWeight);
        TextView mTvProductName = holder.findViewById(R.id.mTvProductName);
        TextView mTvDeepStation = holder.findViewById(R.id.mTvDeep);
        TextView mTvStorageArea = holder.findViewById(R.id.mTvStorageArea);
        TextView mTvSender = holder.findViewById(R.id.mTvSender);
        TextView mTvWarehousingTime = holder.findViewById(R.id.mTvWarehousingTime);

        CommonUtils.setScreenViewVisible(mTvSender);
        CommonUtils.setScreenViewVisible(mTvWarehousingTime);

        mTvOrderNo.setText(data.getOrderNo());
        mTvProductName.setText(data.getTradeName());
        mTvDeepStation.setText(data.getDeap());
        mTvRealCount.setText(String.valueOf(data.getNum()));
        mTvRealWeight.setText(String.valueOf(data.getRealWeight()));
        mTvStorageArea.setText(String.valueOf(data.getWarehouseAreaId()));
        mTvSender.setText(data.getSenderName());
        mTvWarehousingTime.setText(CommonUtils.getTimeNorm(data.getInstorageTime()));

        if(IsEditor)
            setOnItemClickListener(mLlContainerItem , position);
    }
}
